Prev Next |
Sitecore Queries are used for populating the lists in lookup-type Sitecore fields and also in the API.
The Source field is used to populate the lookup fields.
1.1. Specifying the Source
Fill the Source field with a query expression:
The Source defines a set of Items which will populate the lookup field.
The main benefit of the query expressions is that they make it possible to retrieve plain lists of Items regardless of the content tree hierarchy.
Like XPath, which implements XML Node attributes for the simplification of query creation, Sitecore Query has a set of standard attributes accessed with the '@@' sign. For instance:
-
@@
name
– Item name.
- @@ templateid - Item ' s template ID .
Item fields are accessed by adding the ‘@’ sign. For example: @Title refers to a field called Title.
1.2. API Application
Please refer to the Internal Architecture section for details concerning the Sitecore Query implementation in the API.
1.3. Handling the Output
The output of the query expression can be handled by using the following snippet:
{
Query query = newQuery(sitecoreQuery);
QueryContext queryContext = newQueryContext(Sitecore.Configuration.Factory.GetDatabase("master").DataManager);
object result = query.Execute(queryContext);
return (QueryContext[])result;
}
...
Prev Next